#include <STC15F2K60S2.H>
#include "Relay.h"
#include "Delay.h"


unsigned char code NixieTable[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};


/**********************************************************************************************/
/**锁存器初始化
	* @brief  选择锁存器；继电器，蜂鸣器0xa0；LED0x80；数码管位选端0xd0，段选端0xf0；
	* @param  latch选择相对应的锁存器； P0Data控制P0电平；蜂鸣器P0^6高电平打开;
						继电器P0^5高电平打开；
	* @retval  无
	*/
void Latch_Init(uint8_t latch,uint8_t P0Data)
{
	P2=(P2&0X1f|latch);
	P0=P0Data;
	P2&=0X1F;
}
/**********************************************************************************************/

/**********************************************************************************************/
//数码管显示
void Nixie_Show(uint8_t position,unsigned int number)
{
	switch(position)
	{
		case 1:Latch_Init(Nixie_W,0x01<<(position-1));Latch_Init(Nixie_D,NixieTable[number]);break;
		case 2:Latch_Init(Nixie_W,0x01<<(position-1));Latch_Init(Nixie_D,NixieTable[number]);break;
		case 3:Latch_Init(Nixie_W,0x01<<(position-1));Latch_Init(Nixie_D,NixieTable[number]);break;
		case 4:Latch_Init(Nixie_W,0x01<<(position-1));Latch_Init(Nixie_D,NixieTable[number]);break;
		case 5:Latch_Init(Nixie_W,0x01<<(position-1));Latch_Init(Nixie_D,NixieTable[number]);break;
		case 6:Latch_Init(Nixie_W,0x01<<(position-1));Latch_Init(Nixie_D,NixieTable[number]);break;
		case 7:Latch_Init(Nixie_W,0x01<<(position-1));Latch_Init(Nixie_D,NixieTable[number]);break;
		case 8:Latch_Init(Nixie_W,0x01<<(position-1));Latch_Init(Nixie_D,NixieTable[number]);break;
	}
	Delay(2);
	Latch_Init(Nixie_D,0xff);
}


/**********************************************************************************************/


